package com.huangliusong.sm.service.impl;

import com.huangliusong.sm.dao.SelfDao;
import com.huangliusong.sm.dao.StaffDao;
import com.huangliusong.sm.entity.Staff;
import com.huangliusong.sm.service.SelfService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service("selfService")
public class SelfServiceImpl implements SelfService {
    @Resource
    private SelfDao selfDao;
    @Resource
    private StaffDao staffDao;

    public Staff login(String account, String password) {
        Staff staff=selfDao.selectByAccount(account);
        if (staff==null){
            return null;
        }
        if(staff.getPassword().equals(password)){
            return staff;
        }
        return null;
    }

    public void changePassword(Integer id, String password) {
      Staff staff=  staffDao.selectById(id);
      staff.setPassword(password);
      staffDao.update(staff);
    }
}
